<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>WS DNS Lookup Service Documentation</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0 2rem;
            background-color: #f5f5f5;
        }
        h1, h2 {
            color: #2c3e50;
        }
        pre {
            background-color: #ecf0f1;
            padding: 1rem;
            border-radius: 5px;
            overflow-x: auto;
        }
        code {
            font-family: Consolas, "Courier New", monospace;
            font-size: 1rem;
        }
        ul {
            line-height: 1.8;
        }
        .note {
            background-color: #e7f3fe;
            border-left: 6px solid #2196F3;
            margin: 1rem 0;
            padding: 0.5rem 1rem;
        }
        a {
            text-decoration: none;
            color: #2980b9;
            font-size: 1.2rem;
            font-weight: bold;
        }
        a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <a href="rest-services.html">REST Services Home Page</a>
    <h1>WS DNS Lookup Service Documentation</h1>
    <p>
        Welcome to the <strong>WS DNS Lookup Service</strong>. This service allows you to perform a DNS lookup 
        by providing a hostname. It’s useful for testing network configurations and ensuring that your application 
        can resolve domain names correctly.
    </p>

    <div class="note">
        <strong>Note for Beginners:</strong> 
        In this documentation, you’ll find examples of how to interact with the service using 
        <strong>Burp Repeater</strong> (for testing purposes) and <code>curl</code> (for command-line users). 
        If you’re new to these tools, follow the steps carefully, and soon you’ll be making requests with ease.
    </div>

    <h2>Endpoint</h2>
    <p>The service is accessible at the following endpoint:</p>
    <pre><code>POST /webservices/rest/ws-dns-lookup.php</code></pre>

    <h2>How It Works</h2>
    <p>Provide a hostname in the request body, and the service will perform a DNS lookup for that hostname. 
    If the security level is set high, the service will validate the hostname to protect against malicious input.</p>

    <h2>Request Parameters</h2>
    <ul>
        <li><b>hostname</b> (string, required): The hostname you want to resolve (e.g., <code>google.com</code>).</li>
    </ul>

    <h2>Step-by-Step Example Using Burp Repeater</h2>
    <p>Here’s how to send a request to this service using Burp Repeater:</p>
    <pre><code>POST /webservices/rest/ws-dns-lookup.php HTTP/1.1
Host: mutillidae.localhost
Content-Type: application/json
Accept: application/json
Origin: http://mutillidae.localhost
Connection: close

{
    "hostname": "google.com"
}</code></pre>

    <p><strong>Instructions:</strong></p>
    <ol>
        <li>Open Burp Suite and navigate to the Repeater tab.</li>
        <li>Copy the above request and paste it into the Repeater window.</li>
        <li>Click <strong>Send</strong> to see the response from the server.</li>
    </ol>

    <h2>Example Using <code>curl</code> (Command Line)</h2>
    <p>If you prefer using the command line, here’s how you can make the same request with <code>curl</code>:</p>
    <pre><code>curl -X POST "http://mutillidae.localhost/webservices/rest/ws-dns-lookup.php" \
 -H "Content-Type: application/json" \
 -H "Host: mutillidae.localhost" \
 -H "Accept: application/json" \
 -H "Origin: http://mutillidae.localhost" \
 -H "Connection: close" \
 -d '{"hostname": "google.com"}'</code></pre>

    <p><strong>Instructions:</strong></p>
    <ol>
        <li>Open a terminal or command prompt.</li>
        <li>Copy and paste the above <code>curl</code> command.</li>
        <li>Press <strong>Enter</strong> to send the request and view the response.</li>
    </ol>

    <h2>Expected Response</h2>
    <p>If everything works correctly, you will receive a response like this:</p>
    <pre><code>{
    "hostname": "google.com",
    "command": "nslookup 'google.com'",
    "security-level": 5,
    "result": "Server:  8.8.8.8\nAddress: 142.250.190.78"
}</code></pre>

    <div class="note">
        <strong>Troubleshooting Tips:</strong> 
        If you encounter any issues:
        <ul>
            <li>Ensure that the <code>mutillidae.localhost</code> host is correctly configured in your environment.</li>
            <li>Check that the service is running and accessible.</li>
            <li>If using Burp Suite, verify that traffic is correctly routed to the service.</li>
        </ul>
    </div>

    <h2>Learn More</h2>
    <p>If you want to explore more, try providing different hostnames and observe the results. 
    For example, you can send the hostname <code>example.com</code> and check if it resolves correctly.</p>
</body>
</html>
